package com.easyedu.core.dao;

import com.easyedu.core.entity.po.Teacher;
import com.easyedu.core.entity.query.TeacherQuery;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author lmr
 **/
@Mapper
public interface TeacherDao {

     /**
      * 功能描述: select teacher message
      *
      * @param teacherQuery 1 查询老师条件数据
      * @return : java.util.List<com.easyedu.api.entity.DO.Teacher>
      **/
     List<Teacher> getTeacher(TeacherQuery teacherQuery);

     /**
      * 功能描述: 创建教师
      *
      * @param teacher 1 教师信息 teacher表 Persistant Object
      **/
     @Options(useGeneratedKeys = true, keyProperty = "teacherId", keyColumn = "teacher_id")
     @Insert("insert into teacher(name, institute_id, institute_name, department_id,"
             + "department_name, `rank`, job, phone, email, profile, create_time, update_time) "
             + "VALUES(#{name},#{instituteId},#{instituteName},#{departmentId},#{departmentName},#{rank},#{job},"
             + "#{phone},#{email},#{profile},NOW(),NOW())")
     void createTeacher(Teacher teacher);

     /**
      * 功能描述:设置教师编号
      *
      * @param teacher 1 教师信息 teacher表 Persistant Object
      **/
     @Update("update teacher set teacher_number = #{teacherNumber} where teacher_id = #{teacherId}")
     void updateTeacherNumber(Teacher teacher);

     /**
      * 功能描述:删除教师
      *
      * @param teacherId 1 教师id
      * @return : java.lang.Integer
      **/
     @Delete("delete from teacher where teacher_id = #{teacherId}")
     Integer deleteTeacher(Long teacherId);

     /**
      * 根据教师id查询教师
      *
      * @param teacherId 1 教师id
      * @return 教师信息
      */
     @Select("select * from teacher where teacher_id = #{teacherId}")
     Teacher getTeacherById(String teacherId);

     @Update("update teacher set institute_id = #{instituteId},institute_name = #{instituteName},department_id = "
             + "#{departmentId},department_name = #{departmentName},rank = #{rank},job = #{job},phone = #{phone},"
             + "email = #{email},profile = #{profile} where teacher_number = #{teacherNumber}")
     Integer updateTeacher(long teacherNumber, String teacherName, long instituteId, String instituteName, long departmentId, String departmentName, String rank, String job, String phone, String email,
             String profile);
}
